package com.aididi.socket.controller;

import com.aididi.annotation.AutoIdempotent;
import com.aididi.service.TokenService;
import com.aididi.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zx.xu
 * @Description:
 */
@RestController
@Slf4j
public class BusinessController {

    @Autowired
    private TokenService tokenService;

    @PostMapping("/get/token")
    public Object createToken(){
        String token = tokenService.createToken();
        return ResponseUtil.ok(token);
    }

    @AutoIdempotent
    @PostMapping("/test/Idempotence")
    @Async
    public Object testIdempotence() {
        String token = "接口幂等性测试";
        log.info("线程---"+Thread.currentThread().getName());
        return ResponseUtil.ok(token) ;
    }

}
